//
//  AppDelegate.m
//  UI-09-作业
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AppDelegate.h"
#import "FistViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
@interface AppDelegate ()<UITabBarControllerDelegate>


@end

@implementation AppDelegate
- (void)dealloc{
    [_window release];
    [super dealloc];
}

/**创建1个标签视图控制器,管理3个导航视图控制,每个导航视图控制器管理一个UIViewController
 要求 :
 1.命名 First ~ Third 
 2.分别设置背景颜 红、黄、绿 
 3.标题第一页~第三页 
 4. 定义UITabbar外观 
 5.第一个标签使 LTView模仿QQ界 
 6.第二个标签显式轮播图*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.window.backgroundColor = [UIColor whiteColor];
    
    [self.window makeKeyAndVisible ];
    // 第一页
    FistViewController * Fist = [[FistViewController alloc]init];
    UINavigationController *Fistmy = [[UINavigationController alloc]initWithRootViewController:Fist];
    UIImage *FistNomelImage = [[UIImage imageNamed:@"Unknown-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage *FistSelectedImage = [[UIImage imageNamed:@"Unknown-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    Fist.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"第一页" image:FistNomelImage selectedImage:FistSelectedImage];
    
    
    // 第二页
    SecondViewController * Second = [[SecondViewController alloc]init];
    UINavigationController *Secondmy = [[UINavigationController alloc]initWithRootViewController:Second];
    UIImage *SecondNomelImage = [[UIImage imageNamed:@"Unknown-8"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage *SecondSelectedImage = [[UIImage imageNamed:@"Unknown-9"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    Second.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"第二页" image:SecondNomelImage selectedImage:SecondSelectedImage];
    
    
    // 第三页
    ThirdViewController * Third = [[ThirdViewController alloc]init];
    UINavigationController *thirdmy = [[UINavigationController alloc]initWithRootViewController:Third];
    UIImage *ThirdNomelImage = [[UIImage imageNamed:@"Unknown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage *ThirdSelectedImage = [[UIImage imageNamed:@"Unknown-3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    Third.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"第三页" image:ThirdNomelImage selectedImage:ThirdSelectedImage];

    
    /**创建UITabBarController*/
    UITabBarController *tabBar = [[UITabBarController alloc]init];
    // 核心API
    tabBar.viewControllers = @[Fistmy, Secondmy, thirdmy];
    
    /**设置bar的颜色*/
    tabBar.tabBar.barTintColor = [UIColor lightGrayColor];
    tabBar.tabBar.tintColor = [UIColor greenColor];
    tabBar.tabBar.translucent = NO;
    tabBar.tabBar.barStyle = UIBarStyleBlack;/**会受到 barTintColor的影响*/
    
    /**代理人*/
    tabBar.delegate = self;
    // tabBar.tabBar.delegate = self;
    
    
    /**UIappearance*/
    [[UITabBar appearance] setTintColor:[UIColor redColor]];
    [[UITabBar appearance] setBarTintColor:[UIColor grayColor]];
    
    [[UINavigationBar appearance] setBarTintColor:[UIColor grayColor]];
    
    // 将tabBar指定为window的根控制器
    self.window.rootViewController = tabBar;
    
    
    // 内存管理
    [_window release];
    [Fist release];
    [Fistmy release];
    [Second release];
    [Secondmy release];
    [Third release];
    [thirdmy release];
    
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
